<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        {$title}
    </title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <meta http-equiv="Cache-Control" content="no-transform " />
    <meta name="Keywords" content="{$keywords}" />
    <meta name="Description" content="{$description}" />
    <link rel="stylesheet" href="__STATIC__/index/css/base.css" type="text/css" />
    <link rel="stylesheet" href="__STATIC__/index/css/moco.min.css" type="text/css" />
    <script charset="utf-8" src="__STATIC__/index/js/jquery.js">
    </script>
</head>
<body id="index">

{include file="common:header" /}

<div id="main" style="height: auto">

    {block name="body"}{/block}

</div>

{block name="script"}{/block}

{include file="common:footer" /}

<link rel="stylesheet" href="__STATIC__/index/css/login.css" type="text/css" />
<div id="signin" class="rl-modal in" style="display: none;">
    <div class="rl-modal-header">
        <h1>
			<span class="active-title" onclick="$('#js-signin-btn').click()">
				登录
			</span>
			<span data-fromto="signin:signup" class="xa-showSignup" onclick="$('#js-signup-btn').click()">
				注册
			</span>
        </h1>
        <button type="button" class="rl-close" data-dismiss="modal" hidefocus="true"
                aria-hidden="true">
        </button>
    </div>
    <div class="rl-modal-body js-loginWrap">
        <div class="clearfix">
            <div class="l-left-wrap l">
                <form id="signup-form" autocomplete="off">
                    <p class="rlf-tip-globle color-red" id="signin-globle-error">
                    </p>
                    <div class="rlf-group pr">
                        <input id="login-username" type="text" value="" maxlength="37" name="username" data-validate="require-email"
                               autocomplete="off" class="xa-emailOrPhone ipt ipt-email js-own-name" placeholder="请输入登录邮箱/手机号">
                        <p id="login-username-tips" class="rlf-tip-wrap errorHint color-red" data-error-hint="请输入正确的邮箱或手机号">
                        </p>
                    </div>
                    <div class="rlf-group  pr">
                        <input id="login-password" type="password" name="password" data-validate="require-password"
                               class="ipt ipt-pwd js-loginPassword js-pass-pwd" placeholder="6-16位密码，区分大小写，不能用空格"
                               maxlength="16" autocomplete="off">
                        <p id="login-password-tips" class="rlf-tip-wrap errorHint color-red " data-error-hint="请输入6-16位密码，区分大小写，不能使用空格！">
                        </p>
                    </div>
                    <div class="rlf-group clearfix form-control js-verify-row" style="display: none;">
                        <input type="text" name="verify" class="ipt ipt-verify l" data-validate="require-string"
                               data-callback="checkverity" maxlength="4" data-minlength="4" placeholder="请输入验证码">
                        <a href="javascript:void(0)" hidefocus="true" class="verify-img-wrap js-verify-refresh">
                        </a>
                        <a href="javascript:void(0)" hidefocus="true" class="icon-refresh js-verify-refresh">
                        </a>
                        <p class="rlf-tip-wrap errorHint color-red" data-error-hint="请输入正确验证码">
                        </p>
                    </div>
                    <div class="rlf-group rlf-appendix form-control  clearfix">
                        <label for="auto-signin" class="rlf-autoin l" hidefocus="true">
                            <input type="checkbox" checked="checked" class="auto-cbx" id="auto-signin">
                            下次自动登录
                        </label>
                        <a href="#" class="rlf-forget r" target="_blank" hidefocus="true">
                            忘记密码
                        </a>
                    </div>
                    <div class="rlf-group clearfix">
                        <input type="button" value="登录" hidefocus="true" class="btn-red btn-full xa-login">
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div id="signup" class="rl-modal  in" style="display: none;">
    <div class="rl-modal-header">
        <button type="button" class="rl-close" data-dismiss="modal" aria-hidden="true">
        </button>
        <h1>
			<span data-fromto="signup:signin" class="xa-showSignin" onclick="$('#js-signin-btn').click()">
				登录
			</span>
			<span class="active-title" onclick="$('#js-signup-btn').click()">
				注册
			</span>
        </h1>
    </div>
    <div class="rl-modal-body js-modal-body js-registerWrap">
        <form id="signup-form pr">
            <p class="rlf-tip-globle color-red rlf-g-tip" id="signup-globle-error">
            </p>
            <div class="rlf-group  pr">
                <input type="text" maxlength="37" value="" name="email" data-callback="checkusername"
                       data-validate="require-mobile-phone" autocomplete="off" class="xa-emailOrPhone ipt ipt-email "
                       placeholder="请输入注册邮箱/手机号">
                <p class="rlf-tip-wrap errorHint color-red" data-error-hint="请输入正确的邮箱或手机号">
                </p>
            </div>
            <div class="rlf-group proclaim-loc pr xa-passwordWrap hide">
                <a href="javascript:void(0)" hidefocus="true" class="proclaim-btn js-proclaim icon-show-pw is-pwd"
                   tabindex="-1">
                </a>
                <input type="password" name="password" data-validate="require-password"
                       class="ipt ipt-pwd js-pass-pwd" placeholder="6-16位密码，区分大小写，不能用空格" maxlength="16"
                       autocomplete="off">
                <p class="rlf-tip-wrap errorHint color-red " data-error-hint="请输入6-16位密码，区分大小写，不能使用空格！">
                </p>
            </div>
            <div class="rlf-group clearfix form-control ">
                <input type="text" name="verify" class="ipt ipt-verify js-emailverify l"
                       data-validate="require-string" data-callback="checkverity" maxlength="4"
                       data-minlength="4" placeholder="请输入验证码">
                <a href="javascript:void(0)" hidefocus="true" class="verify-img-wrap js-verify-refresh">
                    <img class="verify-img" src="/passport/user/verifycode?t=1492508533296">
                </a>
                <a href="javascript:void(0)" hidefocus="true" class="icon-refresh js-verify-refresh">
                </a>
                <p class="rlf-tip-wrap errorHint color-red" data-error-hint="验证码错误">
                </p>
            </div>
            <div class="rlf-group clearfix">
                <a href="javascript:void(0)" id="signup-btn" hidefocus="true" class="btn-red btn-full btn r">
                    注册
                </a>
            </div>
        </form>
    </div>
</div>
<div class="modal-backdrop in" style="display: none;"></div>
<script>
    $(function(){
        // 登录弹框
        $('#js-signin-btn').click(function(){
            $('#signup').hide();
            $('.modal-backdrop').show();
            $('#signin').show();
        });
        // 注册弹框
        $('#js-signup-btn').click(function(){
            $('#signin').hide();
            $('.modal-backdrop').show();
            $('#signup').show();
        });
        // 关闭弹框
        $('.rl-close').click(function(){
            $('.modal-backdrop').hide();
            $('#signin').hide();
            $('#signup').hide();
        });

        // 登录
        $('.xa-login').click(function(){
            var _username = $.trim($('#login-username').val());
            var _password = $.trim($('#login-password').val());
            if (_username =='') {
                $('#login-username-tips').html($('#login-username-tips').attr('data-error-hint'));
                return false;
            }
            if (_username.indexOf("@") != -1 && !/^[a-z\d]+(\.[a-z\d]+)*\@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$/.test(_username)) {
                $('#login-username-tips').html($('#login-username-tips').attr('data-error-hint'));
                return false;
            }
            if (_username.indexOf("@") == -1 && !(/^1[3578]\d{9}$/.test(_username))) {
                $('#login-username-tips').html($('#login-username-tips').attr('data-error-hint'));
                return false;
            }
            $('#login-username-tips').html('');
            if (_password.length < 6) {
                $('#login-password-tips').html($('#login-password-tips').attr('data-error-hint'));
                return false;
            }
            $('#login-password-tips').html('');

            $.ajax({
                url:'/login',
                data:{username:_username, password:_password},
                type:'post',
                dataType:'json',
                success:function(data){
                    if (data.code == 1001) {
                        $('#login-username-tips').html(data.msg1);
                        $('#login-password-tips').html(data.msg2);
                        return false;
                    }
                    if (data.code == 1002 || data.code == 1003) {
                        $('#login-username-tips').html(data.msg);
                        return false;
                    }
                    window.location.reload();
                },
                error:function(){
                    $('#login-username-tips').html('网络错误，请稍后重试');
                }
            });
        });
    });
</script>

</body>
</html>